home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / hplip / ui4 / settingsdialog.py < prev    next >
Text File  |  2009-10-09  |  3KB  |  97 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. # Local
  23. from base.g import *
  24. from base.codes import *
  25. from ui_utils import *
  26.  
  27. # Qt
  28. from PyQt4.QtCore import *
  29. from PyQt4.QtGui import *
  30. from settingsdialog_base import Ui_SettingsDialog_base
  31.  
  32.  
  33.  
  34. class SettingsDialog(QDialog, Ui_SettingsDialog_base):
  35.     def __init__(self, parent=None):
  36.         QDialog.__init__(self, parent)
  37.         self.setupUi(self)
  38.  
  39.         self.connect(self.SetDefaultsButton, SIGNAL("clicked()"),  self.SetDefaultsButton_clicked)
  40.  
  41.         self.user_settings = UserSettings()
  42.         self.user_settings.load()
  43.  
  44.         self.SystemTraySettings.initUi(self.user_settings.systray_visible,
  45.                                        self.user_settings.polling,
  46.                                        self.user_settings.polling_interval,
  47.                                        self.user_settings.device_list,
  48.                                        self.user_settings.systray_messages)
  49.  
  50.         self.updateControls()
  51.  
  52.  
  53.     def updateControls(self):
  54.         self.AutoRefreshCheckBox.setChecked(self.user_settings.auto_refresh)
  55.         self.AutoRefreshRateSpinBox.setValue(self.user_settings.auto_refresh_rate) # min
  56.         if self.user_settings.auto_refresh_type == 1:
  57.             self.RefreshCurrentRadioButton.setChecked(True)
  58.         else:
  59.             self.RefreshAllRadioButton.setChecked(True)
  60.  
  61.         self.ScanCommandLineEdit.setText(self.user_settings.cmd_scan)
  62.         self.SystemTraySettings.systray_visible = self.user_settings.systray_visible
  63.         self.SystemTraySettings.systray_messages = self.user_settings.systray_messages
  64.         self.SystemTraySettings.updateUi()
  65.  
  66.  
  67.     def updateData(self):
  68.         self.user_settings.systray_visible = self.SystemTraySettings.systray_visible
  69.         self.user_settings.systray_messages = self.SystemTraySettings.systray_messages
  70.         self.user_settings.cmd_scan = unicode(self.ScanCommandLineEdit.text())
  71.         self.user_settings.auto_refresh = bool(self.AutoRefreshCheckBox.isChecked())
  72.  
  73.         if self.RefreshCurrentRadioButton.isChecked():
  74.             self.user_settings.auto_refresh_type = 1
  75.         else:
  76.             self.user_settings.auto_refresh_type = 2
  77.  
  78.         self.user_settings.auto_refresh_rate = self.AutoRefreshRateSpinBox.value()
  79.  
  80.  
  81.     def SetDefaultsButton_clicked(self):
  82.         self.user_settings.loadDefaults()
  83.         self.updateControls()
  84.  
  85.  
  86.     def accept(self):
  87.         self.updateData()
  88.         self.user_settings.save()
  89.         QDialog.accept(self)
  90.  
  91.         # TODO: Need a way to signal hp-systray if systray_visible has changed
  92.  
  93.     def __tr(self,s,c = None):
  94.         return qApp.translate("SettingsDialog",s,c)
  95.  
  96.  
  97.